function CheckAll(form) {  
	for (var i=0;i<form.elements.length;i++)  {  
		var e = form.elements[i];  
		if (e.name != 'chkall')  
		e.checked = true // form.chkall.checked;  
	}  
} 
 
function ContraSel(form) {
	for (var i=0;i<form.elements.length;i++){
		var e = form.elements[i];
		if (e.name != 'chkall')
		e.checked=!e.checked;
	}
}
function detectMacXFF() {
  var userAgent = navigator.userAgent.toLowerCase();
  if (userAgent.indexOf('mac') != -1 || userAgent.indexOf('firefox')!=-1 || userAgent.indexOf('opera')!=-1) {
	return true;
  }else{
	return false;
  }
}
function json_decode(data){
	return (new Function("","return "+data))();
}
function lab_err(obj,txt){
	obj.style.cssText ="border:#f00 1px solid;";
	obj.parentNode.lastChild.className="lab_err";
	obj.parentNode.lastChild.innerText=txt;
}
function dalert(data) {
	if ( typeof data == "string")data =(new Function("","return "+data))();
	data.time=data.time?data.time:2000;
	if(data.url && data.time==1){
		window.location.href=data.url;
		return false;
	}
	var d = dialog({
		title: '提示',
		content: data.message,
		okValue: '确定',
		skin: 'tip'+data.status,
		ok: function () {}
	}).show();
	if(data.status=="ok"){
		setTimeout(function () {
			d.close().remove();
			if(data.url)window.location.href=data.url;
		}, data.time);
	}
}
function k_ajaxForm(form,url,reset){
	var options = {
		beforeSubmit: showRequest,  //提交前的回调函数
		success: showResponse,      //提交后的回调函数
		url: url,                 //默认是form的action， 如果申明，则会覆盖
		resetForm: reset,
		timeout: 3000               //限制请求的时间，当请求大于3秒后，跳出请求
	}
	$(form).ajaxForm(options);
}
function showResponse(responseText, statusText)  {
	dalert(responseText);
}

function del(url,confirm){
	if(!confirm){
		jump_json(url);
		return true;
	}
	dialog({
		title: '提示',
		content: '你确定要删除吗?',
		okValue: '确定',
		skin: 'tipquestion',
		ok: function () {
			jump_json(url);
			return true;
		},
		cancelValue: '取消',
		cancel: function () {}
	}).show();
}
function jump_json(url){
	$.getJSON(url,function(json){
		if(json.status=='ok'){
			if(json.url){
				window.location.href=json.url;
			}else{
				window.location.reload();
			}
		}else{
			dalert(json);
		}
	});
}
function is_show(obj,url){
	if(obj.className=='ok'){
		obj.className='hide';
		$.get(url);
	}else{
		obj.className='ok';
		$.get(url);
	}
	return true;
}